home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 705 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.1 KB

  1. Path: news.clark.net!not-for-mail
  2. From: gusty@clark.net (Harlan Messinger)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: void pointers
  5. Date: 5 Jan 1996 22:27:44 GMT
  6. Organization: Clark Internet Services, Inc., Ellicott City, MD USA
  7. Message-ID: <4ck8l0$3ec@clarknet.clark.net>
  8. References: <Pine.SUN.3.91.960105113409.18158A-100000@phoenix.acms.arizona.edu>
  9. NNTP-Posting-Host: explorer.clark.net
  10. Mime-Version: 1.0
  11. Content-Type: TEXT/PLAIN; charset=ISO-8859-1
  12. Content-Transfer-Encoding: 8bit
  13. X-Newsreader: TIN [UNIX 1.3 950726BETA PL0]
  14.  
  15. Kenton White (jwhite@phoenix.acms.arizona.edu) wrote:
  16. : I am trying to create a class that stores pointers to other classes in an
  17. : array of void pointers.  Since void pointers cannot be dereferenced, is
  18. : there any way to cast the void pointer to a non-void pointer and then
  19. : dereference? 
  20.  
  21. Absolutely, as long as you know at the point in the code where the 
  22. dereferencing is to take place what type of pointer it should be.
  23.  
  24. If the different classes have a common base class, or SHOULD have a 
  25. common base class, then it's better to have an array of pointers to the 
  26. base class and a set of virtual functions.
  27.